 
local function setChannel(channel, value)
    channel:clear()
    channel:push(value)
end
    

local socket = require("socket")
local unitID = ...

local client = socket.tcp()

client:connect("localhost",1337)
client:send("flosama\n{\"PositionStream\":{\"target\":{\"Selected\":["..unitID.."]}}}\n")

repeat
    local received = client:receive('*l')
    local channel = love.thread.getChannel('info')
    local ending = love.thread.getChannel('kill'):pop();
    print(ending);
    channel:performAtomic(setChannel, received)    
until (received == nil or ending ~= nil)
